<?php
namespace app\model;
use app\BaseModel;
use think\model\concern\SoftDelete;
use app\model\Member;

class MemberRecharge extends BaseModel
{

    use SoftDelete;
    protected $deleteTime = 'delete_time';
    protected $defaultSoftDelete = '0000-00-00 00:00:00';
    protected $hidden = ['update_time','delete_time','sort','status'];


    public function searchMemberIdAttr($query, $value, $data)
    {
        if (!empty($value)) {
            $query->where('member_id', '=', $value);
        }
    }

    protected function setMemberIdAttr($value, $data)
    {
        //当前字段的修改器
        $member = Member::where('id', $value)->find();
        $this->set('member_mobile', $member['mobile']);
        $this->set('member_name', $member['name']);
        return $value;
    }

    public static function saveData($member_id, $price, $order_number, $payment)
    {

        self::create([
            'member_id' => $member_id,
            'price' => $price,
            'order_number' => $order_number,
            'payment' => $payment
        ]);

    }



}